#include <iostream>
#include <memory>
using namespace std;
class Person
{

public:
    Person()
    {
        cout << "Person构造函数\n";
    }
    ~Person()
    {
        cout << "Person析构函数\n";
    }

public:
    void run()
    {
        cout << "run\n";
    }
};
int main()
{
    {

        unique_ptr<Person> p2 = nullptr;
        {
            unique_ptr<Person> p1(new Person);
            p1->run();
            /*Person对象的所有权转移到p2*/
            p2 = std::move(p1);
        }
        cout << "11111111111\n";
        p2->run();
        cout << "2222222\n";
#if 0 /*用不了*/
        unique_ptr<Person> p2(p1);
        unique_ptr<Person> p2 = p1;
#endif
        /*适配数组*/
        // unique_ptr<Person[]> p2(new Person[3]{});
    }
}